home *** CD-ROM | disk | FTP | other *** search
- Path: imaginet.fr!usenet
- From: Serge Paccalin <paccalin@alpes-net.fr>
- Newsgroups: comp.lang.c,alt.msdos.programmer
- Subject: Re: Two strange C problems.
- Date: Sun, 07 Jan 1996 22:10:41 +0100
- Organization: Alpes Networks, Grenoble [Fra]
- Message-ID: <30F036D1.2C3C@alpes-net.fr>
- References: <4cojb2$qog@lugb.latrobe.edu.au>
- NNTP-Posting-Host: alpnet51.alpes-net.fr
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4 (Win95; I)
-
- Gregary John Boyles wrote:
- >
- > I have two C problems.
- > ...
- > PROBLEM 2 :
- >
- > const escape=27;
- > ...
- > If I replace the 27 with \27' or the 13 with '\13' then these loops don't
- > work i.e. an infinite loop results. WHY?
- >
-
- I cannot tell for PROBLEM 1 but PROBLEM 2 is easy.
- When you write '\27' you are using octal, not decimal; in other words,
- '\27' is character 2 * 8 + 7 = 23 (decimal).
- If you wish to represent ESCAPE with its value as a char you must use
- either hexadecimal '\x1b' or octal '\33'.
- There is no way to put a decimal code within quotes but you could also
- use a type cast: const escape=(char)27; should do.
-
- Best regards
- --end of message--
-